{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取movies_dataset.csv文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('data/movies_dataset.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 20548 entries, 0 to 20547\n",
      "Data columns (total 15 columns):\n",
      " #   Column           Non-Null Count  Dtype  \n",
      "---  ------           --------------  -----  \n",
      " 0   Unnamed: 0       20548 non-null  int64  \n",
      " 1   IMDb-rating      19707 non-null  float64\n",
      " 2   appropriate_for  11072 non-null  object \n",
      " 3   director         18610 non-null  object \n",
      " 4   downloads        20547 non-null  object \n",
      " 5   id               20548 non-null  int64  \n",
      " 6   industry         20547 non-null  object \n",
      " 7   language         20006 non-null  object \n",
      " 8   posted_date      20547 non-null  object \n",
      " 9   release_date     20547 non-null  object \n",
      " 10  run_time         18780 non-null  object \n",
      " 11  storyline        18847 non-null  object \n",
      " 12  title            20547 non-null  object \n",
      " 13  views            20547 non-null  object \n",
      " 14  writer           18356 non-null  object \n",
      "dtypes: float64(1), int64(2), object(12)\n",
      "memory usage: 2.4+ MB\n"
     ]
    }
   ],
   "source": [
    "data.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 标称属性，给出每个可能取值的频数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "R                 4384\n",
       "Not Rated         2142\n",
       "PG-13             1968\n",
       "PG                 886\n",
       "TV-14              694\n",
       "TV-MA              406\n",
       "G                  152\n",
       "Unrated            132\n",
       "TV-PG              115\n",
       "TV-G                99\n",
       "TV-Y7               45\n",
       "TV-Y                25\n",
       "Approved             9\n",
       "NC-17                4\n",
       "TV-Y7-FV             3\n",
       "Passed               3\n",
       "MA-17                1\n",
       "TV-13                1\n",
       "Drama                1\n",
       "Drama, Romance       1\n",
       "18+                  1\n",
       "Name: appropriate_for, dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['appropriate_for']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Venky Atluri                                  405\n",
       "Simone Stock                                  403\n",
       "Xavier Manrique                               403\n",
       "John Swab                                     205\n",
       "Neil Jordan                                   205\n",
       "                                             ... \n",
       "Agnieszka Smoczynska                            1\n",
       "Dylan Thomas Ellis                              1\n",
       "Sunil Thakur, Sunil Dhawan, Shivani Thakur      1\n",
       "Suman Mukhopadhyay                              1\n",
       "Shea Sizemore                                   1\n",
       "Name: director, Length: 9672, dtype: int64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['director']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Hollywood / English    14649\n",
       "Bollywood / Indian      2645\n",
       "Tollywood               1172\n",
       "Anime / Kids            1049\n",
       "Wrestling                433\n",
       "Punjabi                  332\n",
       "Stage shows              129\n",
       "Pakistani                 92\n",
       "Dub / Dual Audio          45\n",
       "3D Movies                  1\n",
       "Name: industry, dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['industry']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "English                                 12657\n",
       "Hindi                                    2558\n",
       "English,Spanish                           391\n",
       "Punjabi                                   310\n",
       "English,Hindi                             304\n",
       "                                        ...  \n",
       "English,Korean,Spanish                      1\n",
       "Norwegian,Swedish                           1\n",
       "Spanish,Chinese,English,Maori,French        1\n",
       "Urdu,Punjabi,English                        1\n",
       "Spanish,German,English                      1\n",
       "Name: language, Length: 1168, dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['language']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "13 Feb, 2023    812\n",
       "20 Feb, 2023    607\n",
       "15 Feb, 2023    607\n",
       "10 Feb, 2023    485\n",
       "16 Feb, 2023    406\n",
       "               ... \n",
       "12 Sep, 2009      1\n",
       "08 Sep, 2009      1\n",
       "01 Sep, 2009      1\n",
       "18 Aug, 2009      1\n",
       "30 Nov, 2011      1\n",
       "Name: posted_date, Length: 4123, dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['posted_date']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Jan 01 1970    962\n",
       "Feb 03 2023    616\n",
       "Feb 17 2023    607\n",
       "Feb 10 2023    410\n",
       "Feb 11 2023    402\n",
       "              ... \n",
       "Sep 05 2003      1\n",
       "Dec 29 2022      1\n",
       "Aug 24 2013      1\n",
       "Jan 12 2014      1\n",
       "Mar 28 1958      1\n",
       "Name: release_date, Length: 4886, dtype: int64"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['release_date']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "The life of a young man and his struggles against the privatization of education.                                                                                                                                                                                                                                                                                                                                                                                                    402\n",
       "Follows\\r\\n a New York City family hiding out in the Hamptons whose bubble is \\r\\npopped when a Bloody Mary-swilling, pot-smoking 'Charlie' comes to bring\\r\\n a lifetime of hurt that might heal them all.                                                                                                                                                                                                                                                                          402\n",
       "It follows Kara Robinson as she survives an abduction and ultimately brings down a serial killer.                                                                                                                                                                                                                                                                                                                                                                                    402\n",
       "Doc\\r\\n facilitates a fragile truce between the Governor and Cartel, trading \\r\\nprosecutorial leniency for finance. With no more truce, Doc is left to \\r\\nfend for himself and protect the one untainted thing in his life: his \\r\\ndaughter, Little Dixie.                                                                                                                                                                                                                        202\n",
       "A\\r\\n young, gay Black man, rejected by his mother and with few options for \\r\\nhis future, decides to join the Marines, doing whatever it takes to \\r\\nsucceed in a system that would cast him aside.                                                                                                                                                                                                                                                                               202\n",
       "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ... \n",
       "Four waves of increasingly deadly attacks have left most of Earth in ruin. Against a backdrop of fear and distrust, Cassie is on the run, desperately trying to save her younger brother. As she prepares for the inevitable and lethal fifth wave, Cassie teams up with a young man who may become her final hope - if she can only trust him.                                                                                                                                        1\n",
       "Yamuna along with her son Laxman locates to Mumbai leaving behind her abusive husband.She takes shelter in the house of her aunt Chandra whom she calls Akka.Yamuna's only aim is to give a better education to her son.Chandra finds her a job as sweeper in a art school.Yamuna finds that Chandra poses as a nude model to the students of the school.Chandra confines Yamuna to take up the job being nude out there the students don't look at you in lust but as a project.      1\n",
       "A young violinist struggles to assert her individuality amidst the intense pressure of her pianist father, and the weight of her own musical ability.                                                                                                                                                                                                                                                                                                                                  1\n",
       "A right wing talk show host's life takes a sudden turn when his 16 year old niece comes crashing into his life.                                                                                                                                                                                                                                                                                                                                                                        1\n",
       "While driving his car on a rainy night, Anand's car breaks down, and he goes to seek shelter in a nearby house. He is let into the house by the servant, and he is permitted to stay until the rains stop be able to get his car fixed. It is here that he will find out about his previous birth, his true love, Madhumati, their ill-fated, star-crossed and tragic romance, and how events in his previous birth are going to effect him in this life-time.                         1\n",
       "Name: storyline, Length: 15748, dtype: int64"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['storyline']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "The Girl Who Escaped: The Kara Robinson Story    402\n",
       "Vaathi                                           402\n",
       "Who Invited Charlie?                             402\n",
       "Little Dixie                                     202\n",
       "The Inspection                                   202\n",
       "                                                ... \n",
       "Kesari                                             1\n",
       "Old Boys                                           1\n",
       "American Exit                                      1\n",
       "Adventures of Aladdin                              1\n",
       "Madhumati                                          1\n",
       "Name: title, Length: 16572, dtype: int64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['title']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Nicholas Schutt                           403\n",
       "Venky Atluri                              402\n",
       "Haley Harris                              402\n",
       "John Swab                                 205\n",
       "Elegance Bratton                          202\n",
       "                                         ... \n",
       "Barbara Samuels, Joseph Boyden              1\n",
       "Maria Allred                                1\n",
       "Pia Mechler                                 1\n",
       "Paul Flannery, David Ryan Keith             1\n",
       "Khwaja Ahmad Abbas, Khwaja Ahmad Abbas      1\n",
       "Name: writer, Length: 13603, dtype: int64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = data['writer']\n",
    "s.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数值属性，给出5数概括及缺失值的个数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5数概括"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>IMDb-rating</th>\n",
       "      <th>id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>20548.000000</td>\n",
       "      <td>19707.000000</td>\n",
       "      <td>20548.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>10273.500000</td>\n",
       "      <td>5.762151</td>\n",
       "      <td>222351.199776</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>5931.841001</td>\n",
       "      <td>1.374041</td>\n",
       "      <td>138422.327931</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.100000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>5136.750000</td>\n",
       "      <td>4.800000</td>\n",
       "      <td>96122.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>10273.500000</td>\n",
       "      <td>5.700000</td>\n",
       "      <td>264457.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>15410.250000</td>\n",
       "      <td>6.600000</td>\n",
       "      <td>354561.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>20547.000000</td>\n",
       "      <td>9.900000</td>\n",
       "      <td>372092.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Unnamed: 0   IMDb-rating             id\n",
       "count  20548.000000  19707.000000   20548.000000\n",
       "mean   10273.500000      5.762151  222351.199776\n",
       "std     5931.841001      1.374041  138422.327931\n",
       "min        0.000000      1.100000       1.000000\n",
       "25%     5136.750000      4.800000   96122.250000\n",
       "50%    10273.500000      5.700000  264457.500000\n",
       "75%    15410.250000      6.600000  354561.250000\n",
       "max    20547.000000      9.900000  372092.000000"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "缺失值的个数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "841"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['IMDb-rating'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['downloads'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['views'].isnull().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAPT0lEQVR4nO3dcWyc9XnA8e+TpHOAstaDzuvaqWFL1MVLVbq5W1nR5JA2GmsZk5ppZOvUQkaUaMq6CkEI1mAwoZSyZUVBU+QUCFO7tGuKtBWkQJTkVqVpWZMuVYONlKjQrm1G6RK6BsUG4md/+HCdEMdn3/nOv973I1m+e++9ex/Q6cvL6/e9i8xEklSeOa0eQJI0PQZckgplwCWpUAZckgplwCWpUPOaubFLL700FyxY0MxNSjV58cUXueiii1o9hnROBw8e/FFmvuns5U0N+IIFCzhw4EAzNynVpFKp0Nvb2+oxpHOKiO+ca7mHUCSpUAZckgplwCWpUJMGPCIejIgfRsThcct+ISJ2RcSR6u/OmR1TknS2WvbAtwG/f9ayW4HdmbkI2F29L0lqokkDnplfBo6ftfha4OHq7YeBP2rsWFJzbN++nSVLlrBs2TKWLFnC9u3bWz2SVLPpnkbYlZnHADLzWET84kQrRsRqYDVAV1cXlUplmpuUGmv37t088MAD3HzzzVx22WU888wz3HTTTQwMDLBs2bJWjydNKmr5ONmIWAA8mplLqvdfyMw3jnv8RGZOehy8p6cnPQ9cs8WSJUvYvHkzS5cuHTsPfO/evaxbt47Dhw9P/gJSk0TEwczsOXv5dM9CeS4i3lx94TcDP6xnOKkVBgcHufLKK89YduWVVzI4ONiiiaSpmW7A/x34SPX2R4B/a8w4UvMsXryYffv2nbFs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qP5xcg6jh2Em29YLEbEV+BbwLPD1cQ9vA7ZExCkmPhxztr8GPhMRNwGPAT+u8XnShLyUXmqCiLgQOJWZGRHXASsz89pWz6WyuQcuNcdvAfdHRAAvADe0dhz9LHAPXJIK5R8xJalQBlySCmXAJalQBlySCmXAJalQ/w9lHFKG+S8UaAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.boxplot(column='IMDb-rating')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[<AxesSubplot:title={'center':'IMDb-rating'}>]], dtype=object)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEICAYAAACzliQjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUsklEQVR4nO3df5Dc9X3f8ecrkoNlMDEUc5ElNaKtahtQbReVkjDtXINd1JCJyLRMlSFG8tDRhMGt09FMKjztOGmtGTJTPAmtIVUdB1E7JqpjBtWE1IycayYdMBY2jSwwRTEKViWQf5QakQ7l8Lt/7JdkfXfS7Ul3u3f6PB8zO/vd935/fPYzu6/7fj/f7+6lqpAkteGHRt0ASdLwGPqS1BBDX5IaYuhLUkMMfUlqiKEvSQ0x9KVOksNJ3jvkbf5Gkn81zG2qbYa+lpzXwznJ1iSV5GNTnr++q9/TPV7bPT7R3V5I8vkk7xtyu7cm+aP+WlX9QlX9m2G2Q20z9LXU/Qnwj5Ms76vdBPzPGeZ9S1WdB7wLeBi4P8nW+WjElO1Li5ahr6XueeAAcC1AkguBnwD2nmyBqnq+qn4d+G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6qqj426PaNWVbdV1eqqWkvvpNwXq6r5vbeqeh74ZpK3d6Vr8CfGnwOuSvKm7nN0DY2f3O6zF9jSTW8BHjjdFQ37VzZbcDXwfuBAkie62oer6vdG1yQtUv8U+HT3O1TfAD4w4vaMVFV9Kclnga/QuwruqzT4cwxJPgOMAxclOQJ8BLgd2JPkZnp/HG847fX7MwyS1A6HdySpIYa+JDXE0Jekhhj6ktQQQ1+SGmLoS1JDDH1Jasj/B0eY84AtWAUuAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.hist(column='IMDb-rating')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据缺失的处理"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 删除列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9476"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['appropriate_for'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(20548, 15)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "del data['appropriate_for']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(20548, 14)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 用最高频率值来填补缺失值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0           John Swab\n",
       "1         Paul Ziller\n",
       "2        Ben Wheatley\n",
       "3        Venky Atluri\n",
       "4        Shaji Kailas\n",
       "             ...     \n",
       "20543             NaN\n",
       "20544       Bimal Roy\n",
       "20545             NaN\n",
       "20546             NaN\n",
       "20547             NaN\n",
       "Name: director, Length: 20548, dtype: object"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['director']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取最高频率的值\n",
    "mode = data['director'].value_counts().index[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 填补缺失值\n",
    "data['director'].fillna(mode, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0           John Swab\n",
       "1         Paul Ziller\n",
       "2        Ben Wheatley\n",
       "3        Venky Atluri\n",
       "4        Shaji Kailas\n",
       "             ...     \n",
       "20543    Venky Atluri\n",
       "20544       Bimal Roy\n",
       "20545    Venky Atluri\n",
       "20546    Venky Atluri\n",
       "20547    Venky Atluri\n",
       "Name: director, Length: 20548, dtype: object"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['director']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 使用平均数来填补缺失值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0        4.8\n",
       "1        6.4\n",
       "2        5.2\n",
       "3        8.1\n",
       "4        4.6\n",
       "        ... \n",
       "20543    NaN\n",
       "20544    7.7\n",
       "20545    8.0\n",
       "20546    NaN\n",
       "20547    NaN\n",
       "Name: IMDb-rating, Length: 20548, dtype: float64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['IMDb-rating']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 填补缺失值\n",
    "data['IMDb-rating'].fillna(data['IMDb-rating'].mean(), inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0        4.800000\n",
       "1        6.400000\n",
       "2        5.200000\n",
       "3        8.100000\n",
       "4        4.600000\n",
       "           ...   \n",
       "20543    5.762151\n",
       "20544    7.700000\n",
       "20545    8.000000\n",
       "20546    5.762151\n",
       "20547    5.762151\n",
       "Name: IMDb-rating, Length: 20548, dtype: float64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['IMDb-rating']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 使用前值或者后值来填充"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1768"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['run_time'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0             105\n",
       "1              84\n",
       "2        1h 47min\n",
       "3             139\n",
       "4             122\n",
       "           ...   \n",
       "20543         NaN\n",
       "20544         159\n",
       "20545    1h 50min\n",
       "20546         NaN\n",
       "20547         NaN\n",
       "Name: run_time, Length: 20548, dtype: object"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['run_time']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 前值填充\n",
    "data['run_time'].fillna(method='pad', inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0             105\n",
       "1              84\n",
       "2        1h 47min\n",
       "3             139\n",
       "4             122\n",
       "           ...   \n",
       "20543    2h 36min\n",
       "20544         159\n",
       "20545    1h 50min\n",
       "20546    1h 50min\n",
       "20547    1h 50min\n",
       "Name: run_time, Length: 20548, dtype: object"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['run_time']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
